class MiniNet {
	public constructor() {
	}

	private static _root_url: string;
	private isConnecteed: boolean;

	private static instance: MiniNet;
	public static getInstance(): MiniNet {
		if (this.instance == null) {
			this.instance = new MiniNet();
		}
		return this.instance;
	}



	public static get(address: string, content: any, onGetComplete: Function, onGetIOError?: Function, onGetProgress?: Function) {


		var request = new egret.HttpRequest();
		request.responseType = egret.HttpResponseType.TEXT;
		request.open(address, egret.HttpMethod.GET);
		request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		request.send();
		request.addEventListener(egret.Event.COMPLETE, onGetComplete, content);
		if (onGetIOError !== undefined)
			request.addEventListener(egret.IOErrorEvent.IO_ERROR, onGetIOError, content);
		if (onGetProgress !== undefined)
			request.addEventListener(egret.ProgressEvent.PROGRESS, onGetProgress, content);
	}

	public static post(_root_url: string, address: string, params: string, content: any, onGetComplete: Function, onGetIOError?: Function, onGetProgress?: Function) {

		//_root_url = 'http://127.0.0.1:9100';
		var request = new egret.HttpRequest();
		request.responseType = egret.HttpResponseType.TEXT;
		request.open(_root_url + address, egret.HttpMethod.POST);
		request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		request.send(params);
		request.addEventListener(egret.Event.COMPLETE, onGetComplete, content);
		request.addEventListener(egret.IOErrorEvent.IO_ERROR, () => {


		}, content);

	}
}